#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using JigLibX.Collision;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;
using Microsoft.Xna.Framework.Graphics;
using SqEngine.Components;
using sqengine.Components;
using sqengine.Engine.Common;
#endregion

namespace sqengine.PhysicObjects
{

    public class CapsuleObject : BasicObject
    {
        public CapsuleObject(Game game, string ObjName, Model model, float radius, float length, Matrix orientation, Vector3 position, string c_texture)
            : base(game, model, c_texture)
        {
            body = new Body();
            Name = ObjName;
            collision = new CollisionSkin(body);
            collision.AddPrimitive(new Capsule(Vector3.Transform(new Vector3(-0.5f, 0, 0), orientation), orientation, radius, length), (int)MaterialTable.MaterialID.BouncyNormal);
            body.CollisionSkin = this.collision;
            Vector3 com = SetMass(10.0f);
            body.MoveTo(position + com, Matrix.Identity);

            collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));

            body.EnableBody();
            this.Scale = new Vector3(radius, radius, length / 2);


        }

        public override void ApplyEffects(BasicEffect effect)
        {
            effect.DiffuseColor = ObjColor;

        }

    }
}
